//
// Created by 花如锦 on 2024/5/12.
//

#include "AutoPointer.h"

using namespace std;

template<typename T>
AutoPointer<T> :: ~AutoPointer() {
    // 释放内存
    if (t) {
        // 减少引用计数
        int count = PointerRef::DelRef(t);
        if (count <= 0) {
            delete t;
        }
    }
}

template<typename T>
AutoPointer<T> :: AutoPointer(AutoPointer& Other) {
    // 新增计数器
    PointerRef::AddRef(Other.t);
}
